package metamodel.parser;

/**
 * User: fleipold
 * Date: 03-Dec-2007
 * Time: 01:16:04
 */
public class ExactClassResolver implements ClassResolver {
    final String baseName;
    final String fullyQualifiedClassName;

    public ExactClassResolver(String fullyQualifiedClassName) {
        this.fullyQualifiedClassName = fullyQualifiedClassName;
        baseName = fullyQualifiedClassName.substring(fullyQualifiedClassName.lastIndexOf('.')+1);

    }

    public Class resolveClass(String name) {
        if (name.equals(baseName)){
            try {
                return getClass().getClassLoader().loadClass(fullyQualifiedClassName);
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            }
        } else {
            return null;
        }
    }
    
}
